home *** CD-ROM | disk | FTP | other *** search
- Path: oxy.rust.net!usenet
- From: ebennett@rust.net
- Newsgroups: comp.lang.c++
- Subject: Re: [Q]Assigning function pointer in C/C++.
- Date: Sun, 14 Jan 1996 01:06:28 GMT
- Organization: Rust Net - High Speed Internet in Detroit 810-642-2276
- Message-ID: <4d9ab7$pj1@oxy.rust.net>
- References: <DL3JJu.5nB.0.queen@torfree.net>
- NNTP-Posting-Host: liv-20.rust.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- bh332@freenet.toronto.on.ca (Karim Ladha) wrote:
-
- >How is it possible to assign a declared variable in C++ a pointer to
- >some function member? If you know of a solution, post. Greatly appreciated.
-
- >In C for example;
-
- >...
- >void( far *MyFunc )();
- >...
- >...
-
- >Thank you,
- > Karim A.Ladha - BH332@TorFree.Net
-
- >PS: Using BC++ v4.0 for Windows(tm) - DOS Application.
-
- >--
-
- The syntax for class member function pointers is a little different.
- For example:
-
- class MyClass {
- public:
- void aFunction ();
- };
-
- typeptr (MyClass::*MyFuncPtr) ();
-
- will make MyFuncPtr the correct type. Then:
-
- MyFuncPtr ptr;
- ptr = &MyClass::aFunction;
-
- To call it, given x is an instance of MyClass:
-
- (x->ptr)();
-
- will call it.
-
- Earl
-
-
-